import { getBaseUrl } from '@/services/urlconst';
import { getCompanyID, getPosIDs, getUserDepID, getUserID, requestFunComponFiex } from '@/utils';
import { useRequest } from 'umi';
const baseUrl = getBaseUrl();
// 申请物料接口
export const addMaterialService = (Callback: (res: Record<string, any>) => void) => {
  const request = useRequest(
    (payload) => {
      let bodyParams = {
        ...payload,
        signType: 1,
        state: 1,
        createrID: getUserID(),
        createPositionID: getPosIDs(),
        createDepartmentID: getUserDepID(),
        createCompanyID: getCompanyID(),
      };
      let reqUrl = `${baseUrl}/contractController/addMaterial`;
      return requestFunComponFiex('POST', reqUrl, bodyParams);
    },
    {
      manual: true,
      onSuccess: Callback,
    },
  );

  return {
    addMaterialRun: request?.run,
    addMaterialLoading: request?.loading,
  };
};
